package com.shujia.wyh.mrdemos;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.StringReader;

public class IKTest {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("bigdata23-hadoop/data/test.txt"));
        String s = br.readLine();
        //将这一行将要被分词的数据封装成IK分词的对象
        StringReader stringReader = new StringReader(s);

        //创建一个分词器对象
        IKSegmenter ikSegmenter = new IKSegmenter(stringReader, true);

        Lexeme lexeme = null;
        while ((lexeme=ikSegmenter.next())!=null){
//            String word = lexeme.toString();
            String word = lexeme.getLexemeText(); //获取分词的文本信息
            System.out.println(word);
        }


    }
}
